package com.demo.designmode.factory.simple;

/**
 * @Author: jxm
 * @Description:
 * @Date: 2021/7/6 15:44
 * @Version: 1.0
 */
public class PizzaStore {

    //SimplePizzaFactory的引用
    SimplePizzaFactory factory;

    public PizzaStore(SimplePizzaFactory factory) {
        this.factory = factory;
    }

    //订披萨
    public Pizza orderPizza(String type) {
        Pizza pizza;
        pizza = factory.createPizza(type);       //使用工厂对象的创建方法，而不是直接new。这里不再使用具体实例化

        pizza.prepare();
        pizza.bake();
        pizza.cut();
        pizza.box();

        return pizza;
    }

    public static void main(String[] args) {

        SimplePizzaFactory factory = new SimplePizzaFactory();
        PizzaStore pizzaStore = new PizzaStore(factory);
        pizzaStore.orderPizza("cheese");
    }

}
